package com.qf.day03;

/**
 *  线程三大特性：
 *    1、可见性   volatile 有
 *    2、有序性   volatile 有
 *    3、原子性   volatile 没有      synchronized 有
 */
class DataOne{

    private volatile Integer number = 0;

    //
    public synchronized Integer incr(){

        return ++number;//number = number + 1
    }
}

public class VolatileAtomicDemo {

    public static void main(String[] args) {

        DataOne dataOne = new DataOne();

        for (int i = 0; i < 1000; i++) {
            new Thread(() -> {
                System.out.println(dataOne.incr());
            }).start();
        }
    }
}